package com.applet.controller.admin;

import com.applet.common.vo.Result;
import com.applet.pojo.entity.Classify;
import com.applet.pojo.vo.ClassifyVO;
import com.applet.service.ClassifyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author “XuShao”
 * @date 2024/12/16 20:55
 * @description
 */
@RestController
@RequestMapping("/admin/classify")
@Slf4j
@Tag(name = "分类相关接口")
public class ClassifyController {

    @Autowired
    private ClassifyService classifyService;

    @Operation(summary = "查询所有分类")
    @GetMapping
    public Result<List<ClassifyVO>> list() {
        log.info("查询所有分类");

        List<ClassifyVO> classifyVOS = classifyService.getAll();

        return Result.success(classifyVOS);
    }

    @Operation(summary = "根据活动类型查询分类")
    @GetMapping("/{type}")
    public Result<List<ClassifyVO>> showClassifyType(
            @Parameter(
                    name =  "type",
                    description  = "活动分类：0：activity，1：video，2：工作室",
                    required = true)
            @PathVariable Short type
    ) {
        log.info("根据活动分类查询子分类 => {}", type);

        List<ClassifyVO> classifyVOS = classifyService.getType(type);

        return Result.success(classifyVOS);
    }

}
